use "~/HOUSE_TV_BJPS_REP.dta"

***Table 1 Unweighted
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==1 
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==1 & general_candidate==1 & incumbent_opposed==1 
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==1 & general_candidate==1 & incumbent_opposed==1 & viable_opponent==1
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==1 & general_candidate==1 & incumbent_opposed==1 & viable_opponent==0
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==1 & general_candidate==1 & incumbent_opposed==0
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==1 & general_candidate==0 
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==1 & general_candidate==0 & inc_running_for_higher==1 
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==1 & general_candidate==0 & inc_running_for_higher==0 

***Table 2 
reg ad_free_sep  pmd if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.inc_challenge i.inc_not_running if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.incumbent_type_new if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.incumbent_type_new dis_scal opponent_dis_scal abs_diff_dis_scal if  incumbent==1, cl(fullnamedistrict)




***Appendix

**Table A1
reg adfree_pooled_1_2  pmd if  incumbent==1, cl(fullnamedistrict)
reg adfree_pooled_1_2  pmd i.BIG_MEDIA if  incumbent==1, cl(fullnamedistrict)
reg adfree_pooled_1_2  pmd i.BIG_MEDIA pvi_abs if  incumbent==1, cl(fullnamedistrict)
reg adfree_pooled_1_2  pmd i.BIG_MEDIA pvi_abs i.inc_challenge i.inc_not_running if  incumbent==1, cl(fullnamedistrict)
reg adfree_pooled_1_2  pmd i.BIG_MEDIA pvi_abs i.incumbent_type_new  if  incumbent==1, cl(fullnamedistrict)
reg adfree_pooled_1_2  pmd i.BIG_MEDIA pvi_abs i.incumbent_type_new dis_scal opponent_dis_scal abs_diff_dis_scal  if  incumbent==1, cl(fullnamedistrict)


*****Table A6
reg ad_free_sep  pmd i.SINCLAIR if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.SINCLAIR pvi_abs if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.SINCLAIR pvi_abs i.inc_challenge i.inc_not_running if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.SINCLAIR pvi_abs i.incumbent_type_new if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.SINCLAIR pvi_abs i.incumbent_type_new dis_scal opponent_dis_scal abs_diff_dis_scal if  incumbent==1, cl(fullnamedistrict)

***Table A7
reg ad_free_sep  pmd i.PUBLIC if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.PUBLIC pvi_abs if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.PUBLIC pvi_abs i.inc_challenge i.inc_not_running if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.PUBLIC pvi_abs i.incumbent_type_new if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.PUBLIC pvi_abs i.incumbent_type_new dis_scal opponent_dis_scal abs_diff_dis_scal if  incumbent==1, cl(fullnamedistrict)

**Table A8
reg ad_free_sep  pmd extremism i.BIG_MEDIA if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd extremism i.BIG_MEDIA pvi_abs if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd extremism i.BIG_MEDIA pvi_abs i.inc_challenge i.inc_not_running if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd extremism i.BIG_MEDIA pvi_abs i.incumbent_type_new if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd extremism i.BIG_MEDIA pvi_abs i.incumbent_type_new dis_scal opponent_dis_scal abs_diff_dis_scal if  incumbent==1, cl(fullnamedistrict)


***Table A9
reg ad_free_sep  pmd viewer_pop if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd viewer_pop i.BIG_MEDIA if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd viewer_pop i.BIG_MEDIA pvi_abs if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd viewer_pop i.BIG_MEDIA pvi_abs i.inc_challenge i.inc_not_running if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd viewer_pop i.BIG_MEDIA pvi_abs i.incumbent_type_new if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd viewer_pop i.BIG_MEDIA pvi_abs i.incumbent_type_new dis_scal opponent_dis_scal abs_diff_dis_scal if  incumbent==1, cl(fullnamedistrict)


***Table A11
reg ad_free_sep  pmd block_count if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd block_count i.BIG_MEDIA if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd block_count i.BIG_MEDIA pvi_abs if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd block_count i.BIG_MEDIA pvi_abs i.inc_challenge i.inc_not_running if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd block_count i.BIG_MEDIA pvi_abs i.incumbent_type_new if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd block_count i.BIG_MEDIA pvi_abs i.incumbent_type_new dis_scal opponent_dis_scal abs_diff_dis_scal if  incumbent==1, cl(fullnamedistrict)



***Table A12
reg ad_free_sep  pmd approve_count if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA approve_count if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs approve_count if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs approve_count i.inc_challenge i.inc_not_running if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs approve_count i.incumbent_type_new if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs approve_count i.incumbent_type_new dis_scal opponent_dis_scal abs_diff_dis_scal if  incumbent==1, cl(fullnamedistrict)


***Table A13 -- logged
**gen log_dv=log(ad_free_sep+1)
reg log_dv  pmd if  incumbent==1, cl(fullnamedistrict)
reg log_dv  pmd i.BIG_MEDIA if  incumbent==1, cl(fullnamedistrict)
reg log_dv  pmd i.BIG_MEDIA pvi_abs if  incumbent==1, cl(fullnamedistrict)
reg log_dv  pmd i.BIG_MEDIA pvi_abs i.inc_challenge i.inc_not_running if  incumbent==1, cl(fullnamedistrict)
reg log_dv  pmd i.BIG_MEDIA pvi_abs i.incumbent_type_new if  incumbent==1, cl(fullnamedistrict)
reg log_dv  pmd i.BIG_MEDIA pvi_abs i.incumbent_type_new dis_scal opponent_dis_scal abs_diff_dis_scal if  incumbent==1, cl(fullnamedistrict)

***Table A14
reg ad_free_by_week  pmd i.distnum if  incumbent==1, cl(fullnamedistrict)
reg ad_free_by_week  pmd i.distnum i.BIG_MEDIA if  incumbent==1, cl(fullnamedistrict)

***Table A15
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==1
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==1 & party_leader==1
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==1 & committee_chair ==1
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==1 & ranking_member ==1


***Table A16
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.incumbent_type_new loginc logchall logdiff if  incumbent==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs logincplus logchallplus logdiffplus if  incumbent==1, cl(fullnamedistrict)


***Challenger Data

use "~\BJPS_RR_Data_with_Challengers.dta" 
**Table 3
reg ad_free_sep  pmd if  (inc_challenge==1 | facing_incumbent==1) & general_candidate==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA if  (inc_challenge==1 | facing_incumbent==1 ) & general_candidate==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs if  (inc_challenge==1 | facing_incumbent==1) & general_candidate==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.incumbent if  (inc_challenge==1 | facing_incumbent==1) & general_candidate==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.incumbent dis_scal opponent_dis_scal  if  (inc_challenge==1 | facing_incumbent==1) & general_candidate==1, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.incumbent dis_scal opponent_dis_scal abs_diff_dis_scal  if  (inc_challenge==1 | facing_incumbent==1) & general_candidate==1, cl(fullnamedistrict)

reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.incumbent dis_scal opponent_dis_scal  if general_candidate==1 & ((viable_opponent==1 & incumbent==1) | (viable==1 & facing_incumbent==1) | (viable_opponent==1 & viable==1)), cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.incumbent dis_scal opponent_dis_scal abs_diff_dis_scal if general_candidate==1 & ((viable_opponent==1 & incumbent==1) | (viable==1 & facing_incumbent==1) | (viable_opponent==1 & viable==1)), cl(fullnamedistrict)



**Table A2
reg adfree_pooled_1_2  pmd if  (facing_incumbent==1 | open==1) & general_candidate==1 & incumbent==0, cl(fullnamedistrict)
reg adfree_pooled_1_2  pmd i.BIG_MEDIA if  (facing_incumbent==1 | open==1) & general_candidate==1 & incumbent==0, cl(fullnamedistrict)
reg adfree_pooled_1_2  pmd i.BIG_MEDIA pvi_abs if  (facing_incumbent==1 | open==1) & general_candidate==1 & incumbent==0, cl(fullnamedistrict)
reg adfree_pooled_1_2  pmd i.BIG_MEDIA pvi_abs i.faced_primary_challenge if  (facing_incumbent==1 | open==1) & general_candidate==1 & incumbent==0, cl(fullnamedistrict)
reg adfree_pooled_1_2  pmd i.BIG_MEDIA pvi_abs i.competitive_primary if  (facing_incumbent==1 | open==1) & general_candidate==1 & incumbent==0, cl(fullnamedistrict)
reg adfree_pooled_1_2  pmd i.BIG_MEDIA pvi_abs i.competitive_primary dis_scal opponent_dis_scal abs_diff_dis_scal i.open if  (facing_incumbent==1 | open==1) & general_candidate==1 & incumbent==0, cl(fullnamedistrict)
reg adfree_pooled_1_2  pmd i.BIG_MEDIA pvi_abs i.competitive_primary##i.viable i.open  if  (facing_incumbent==1 | open==1) & general_candidate==1 & incumbent==0, cl(fullnamedistrict)
reg adfree_pooled_1_2  pmd i.BIG_MEDIA pvi_abs i.competitive_primary i.viable##i.open   if  (facing_incumbent==1 | open==1) & general_candidate==1 & incumbent==0, cl(fullnamedistrict)


**Table A3
reg ad_free_sep  pmd if  (inc_challenge==1 | facing_incumbent==1) & general_candidate==1, cl(district)
reg ad_free_sep  pmd i.BIG_MEDIA if  (inc_challenge==1 | facing_incumbent==1 ) & general_candidate==1, cl(district)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs if  (inc_challenge==1 | facing_incumbent==1) & general_candidate==1, cl(district)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.incumbent if  (inc_challenge==1 | facing_incumbent==1) & general_candidate==1, cl(district)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.incumbent dis_scal opponent_dis_scal  if  (inc_challenge==1 | facing_incumbent==1) & general_candidate==1, cl(district)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.incumbent dis_scal opponent_dis_scal abs_diff_dis_scal  if  (inc_challenge==1 | facing_incumbent==1) & general_candidate==1, cl(district)

reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.incumbent dis_scal opponent_dis_scal  if general_candidate==1 & ((viable_opponent==1 & incumbent==1) | (viable==1 & facing_incumbent==1) | (viable_opponent==1 & viable==1)), cl(district)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.incumbent dis_scal opponent_dis_scal abs_diff_dis_scal if general_candidate==1 & ((viable_opponent==1 & incumbent==1) | (viable==1 & facing_incumbent==1) | (viable_opponent==1 & viable==1)), cl(district)



***Table A4

reg ad_free_sep  pmd if  (facing_incumbent==1 | open==1) & general_candidate==1 & incumbent==0, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA if  (facing_incumbent==1 | open==1) & general_candidate==1 & incumbent==0, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs if  (facing_incumbent==1 | open==1) & general_candidate==1 & incumbent==0, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.faced_primary_challenge if  (facing_incumbent==1 | open==1) & general_candidate==1 & incumbent==0, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.competitive_primary if  (facing_incumbent==1 | open==1) & general_candidate==1 & incumbent==0, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.competitive_primary dis_scal opponent_dis_scal abs_diff_dis_scal i.open if  (facing_incumbent==1 | open==1) & general_candidate==1 & incumbent==0, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.competitive_primary##i.viable i.open  if  (facing_incumbent==1 | open==1) & general_candidate==1 & incumbent==0, cl(fullnamedistrict)
reg ad_free_sep  pmd i.BIG_MEDIA pvi_abs i.competitive_primary i.viable##i.open   if  (facing_incumbent==1 | open==1) & general_candidate==1 & incumbent==0, cl(fullnamedistrict)

***Table A5
**Row 1
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==0 & general_candidate==1 
**Row 2
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==0 & general_candidate==1 & open==1 

**Row 3
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==0 & general_candidate==1 & open==1 & competitive_primary==1
**Row 4
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==0 & general_candidate==1 & open==1 & competitive_primary==0


**Row 5
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==0 & general_candidate==1 & open==1 & viable==1 & viable_opponent==0

**Row 6
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==0 & general_candidate==1 & open==1 & viable==1 & viable_opponent==1


**Row 7
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==0 & general_candidate==1 & open==1 & viable==0 & viable_opponent==1


**Row 8
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==0 & general_candidate==1 & open==1 & viable==0 & viable_opponent==0

**Row 9
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==0 & general_candidate==1 & open==0 


***Row 10
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==0 & general_candidate==1 & open==0 & competitive_primary==1
**Row 11
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==0 & general_candidate==1 & open==0 & competitive_primary==0

**Row 12
 sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==0 & general_candidate==1 & open==0 & viable==1
**Row 13
sum adfree_pooled_1_by_week adfree_pooled_2_by_week ad_free_by_week if incumbent==0 & general_candidate==1 & open==0 & viable==0


***Governor Data

*Table A10
*Columns 1 and 2
use "~\BJPS_RR_Gov_data.dta" 
sum ad_free_pool_1 ad_free_pool_2 if gov_higher==0
sum ad_free_pool_1 ad_free_pool_2  if gov_reelect==1 & gov_higher==0
sum ad_free_pool_1 ad_free_pool_2  if gov_reelect==0 & gov_higher==0
sum ad_free_pool_1 ad_free_pool_2  if gov_retire==1 & gov_higher==0

*Column 3
use "~\BJPS_RR_GOV_GE.dta"

sum ad_free_by_week if gov_higher==0
sum ad_free_by_week if gov_reelect==1 & gov_higher==0
sum ad_free_by_week if gov_reelect==0 & gov_higher==0
sum ad_free_by_week if gov_retire==1 & gov_higher==0

mean ad_free_by_week if gov_higher==1
